package com.yu.controller;

import javax.servlet.http.HttpSession;

import org.junit.runners.Parameterized.Parameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mysql.jdbc.StringUtils;
import com.yu.bean.Comment;
import com.yu.bean.Msg;
import com.yu.service.CommentService;

@Controller
public class CommentController {
	
	@Autowired
	CommentService commentService;
	
/*	@RequestMapping(value="/addComment", method=RequestMethod.POST)
	@ResponseBody
	public Msg addComment(@RequestParam(value="comContent", required=true) String comContent,
			@RequestParam(value="infoId", required=true) Integer infoId,
			HttpSession session){
		commentService.addComment(infoId, comContent, session);
		//Comment comment = commentService.getAddComment();
		
		return Msg.success();
		
	}*/
	
	/**
	 * 插入评论 并返回coment实体类
	 * @param comment
	 * @param session
	 * @return
	 */
	@RequestMapping(value="/addComment", method=RequestMethod.POST)
	@ResponseBody
	public Msg addComment(Comment comment, HttpSession session){
		commentService.addComment(comment, session);
		Comment com = commentService.getCommentById(comment.getComId());
		System.out.println("插入之后  的评论信息 为=======>"+com);
		return Msg.success().add("comment", com);
		
		
	}

}
